const fs = require('fs') // file system

function read(path) {
  return new Promise(function(resolve, reject) {
    // 异步操作----
    fs.readFile(path, 'utf-8', (err, dataStr) => {
      if (err) return reject(err)
      resolve(dataStr)
    })
    // -----------
  })
}

const p1 = read('./files/1.txt')
const p2 = read('./files/2.txt')
const p3 = read('./files/3.txt')
// console.log(p1, p2, p3)

Promise.all([p1, p2, p3]).then((result) => {
  console.log(result)
})

Promise.race([p1, p2, p3]).then((result) => {
  console.log(result)
})
